﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TrainingWorkshop.IDAL;
using TrainingWorkshop.DAL_EF.Translator;
using System.Data;
namespace TrainingWorkshop.DAL_EF
{
  public   class CourseRepository_EF :ICourseRepository
    {

        public void UpdateCourse(Model.Course c)
        {
           Course courseEF= CourseTranslator.ModelCourseToEF(c);
           using(var db=new projectbEntities())
           {
               lock (this)
               {
                   db.Courses.Attach(courseEF);
                   db.ObjectStateManager.ChangeObjectState(courseEF, EntityState.Modified);
                   db.SaveChanges(); 
               }
           }
        }
    }
}
